package 开始的剑指offer8月.双指针;
// https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/
public class 剑指Offer22链表中倒数第k个节点0823 {

      public class ListNode {
          int val;
          ListNode next;
          ListNode(int x) { val = x; }
      }

    class Solution {
        public ListNode getKthFromEnd(ListNode head, int k) {
            ListNode former = head, latter = head;
            for(int i = 0; i < k; i++)
                former = former.next;
            while(former != null) {
                former = former.next;
                latter = latter.next;
            }
            return latter;
        }
    }


}
